package day10.problem3;

//游游的水果大礼包
//https://ac.nowcoder.com/acm/problem/255193

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextInt();
        long m = in.nextInt();
        long a = in.nextInt(); //2:1 x
        long b = in.nextInt(); //1:2 y
        long ret = 0;
        // ax + by 的最大值
        long k = Math.min(n/2, m); //x的最大值
        for(int x = 0; x <= k; x++) {
            long tn = n - 2*x;
            long tm = m - x;
            long y = Math.min(tm/2, tn);
            ret = Math.max(ret, x*a + y*b);
        }
        System.out.println(ret);
    }
}